#ifndef QGF_TILE_H
#define QGF_TILE_H

#include "kf.h"
#include "kf_types.h"
#include "vector"
#include "hge.h"

class TileTexture
{
public:
	TileTexture(HTEXTURE t, int iw, int ih, int tw, int th):tiles(t),imageWidth(iw), imageHeight(ih), tileWidth(tw),tileHeight(th) 
	{
		tilesAcross = iw/tw;
		tilesDown = ih/th;
	}
	HTEXTURE tiles;
	int tileWidth;
	int tileHeight;
	int imageWidth;
	int imageHeight;
	int tilesAcross;
	int tilesDown;
};

class TileLayer
{
public:
	TileLayer();
	int m_worldWidth;
	int m_worldHeight;
	int m_tileOffsetX;
	int m_tileOffsetY;
	int m_tileIndentX;
	int m_tileIndentY;
	int m_panX;
	int m_panY;
	kf::dword *m_data;
	std::vector<TileTexture> m_textures;
	void init(int wx, int wy);
	void addTiles(HGE *hge, HTEXTURE tiletexture, int tilewidth, int tileheight);
	void render(HGE *hge);
	void setPan(int x, int y);
	void setTileOffset(int x, int y);
	void setTileIndent(int x, int y);
	void clear(unsigned int t);
	kf::dword getTile(int x, int y);
	void setTile(int x, int y, kf::dword t);
	bool loadMap(std::string filename);
};


#endif
